package com.danieldura.highrise.data
{
	import com.adobe.xml.syndication.atom.Entry10;
	
	[Bindable]
	public class Recording
	{
		public static const NOTE:String = "note";
		public static const TASK:String = "task";
		
		public var id:int;
		public var description:String;
		public var title:String;
		public var type:String;
		public var authorId:int;
		public var authorName:String;
		public var authorEmail:String;
		public var note:Note;
		public var kase:Case;
		
		public function parse( entry:Entry10 ):void
		{
			title = entry.title;
			description = entry.content.value;
			
			if( entry.links.length > 0 )
			{
				var link:String = entry.links[0].href;
				
				if( link.indexOf("/notes/") )
				{
					id = Number( link.substring( link.indexOf("/notes/") + 7, link.length ) );
					type = NOTE;	
				}
				else if( link.indexOf( "/task_recordings/" ) )
				{
					id = Number( link.substring( link.indexOf("/task_recordings/") + 17, link.length ) );
					type = TASK;
				}
			}
			
			if( entry.authors.length > 0 )
			{
				var uri:String = entry.authors[0].uri;
				authorId = Number( uri.substring( uri.indexOf("/people/") + 8, uri.length ) );
				authorName = entry.authors[0].name;
				authorEmail = entry.authors[0].email;
			}
		}
		
	}
}